package cn.springcloud.fix.client.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/idx")
public class IndexController {

    @PreAuthorize("hasRole('ADMIN')")
    @RequestMapping("/test")
    public String test() {
        return "SUS";
    }

    @RequestMapping("/getUser")
    public Authentication getUser() {
        return SecurityContextHolder.getContext().getAuthentication();
    }
}
